package cn.wolfcode.luowowo.shop.service.impl;

import cn.wolfcode.luowowo.shop.domain.ShopStrategyTheme;
import cn.wolfcode.luowowo.shop.mapper.ShopStrategyThemeMapper;
import cn.wolfcode.luowowo.shop.query.ShopStrategyThemeQuery;
import cn.wolfcode.luowowo.shop.service.IShopStrategyThemeService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ShopStrategyThemeServiceImpl implements IShopStrategyThemeService {

    @Autowired
    private ShopStrategyThemeMapper shopStegyThemeMapper;


    @Override
    public PageInfo query(ShopStrategyThemeQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(shopStegyThemeMapper.selectForList(qo));
    }

    @Override
    public void saveOrUpdate(ShopStrategyTheme shopStrategyTheme) {
        if(shopStrategyTheme.getId() == null){
            shopStegyThemeMapper.insert(shopStrategyTheme);
        }else{
            shopStegyThemeMapper.updateByPrimaryKey(shopStrategyTheme);        }
    }

    @Override
    public List<ShopStrategyTheme> list() {
        return shopStegyThemeMapper.selectAll();
    }
}
